<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上市公司营收预测分析报告</title>
    <link href="https://cdn.jsdelivr.net/npm/antd@5.12.8/dist/reset.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            margin: 0;
            padding: 20px;
            min-height: 100vh;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        .header {
            background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
            color: white;
            padding: 40px;
            text-align: center;
        }
        .header h1 {
            margin: 0;
            font-size: 2.5em;
            font-weight: 600;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
        }
        .header p {
            margin-top: 10px;
            font-size: 1.2em;
            opacity: 0.9;
        }
        .content {
            padding: 40px;
        }
        .section {
            margin-bottom: 40px;
            background: #fafafa;
            border-radius: 12px;
            padding: 30px;
            border-left: 5px solid #1890ff;
        }
        .section h2 {
            color: #262626;
            font-size: 1.8em;
            margin-bottom: 20px;
            border-bottom: 2px solid #e8e8e8;
            padding-bottom: 10px;
        }
        .section h3 {
            color: #595959;
            font-size: 1.3em;
            margin: 25px 0 15px 0;
        }
        .chart-container {
            width: 100%;
            height: 400px;
            margin: 20px 0;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            border-radius: 8px;
            padding: 10px;
            background: white;
        }
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            transition: transform 0.3s ease;
        }
        .stat-card:hover {
            transform: translateY(-5px);
        }
        .stat-number {
            font-size: 2em;
            font-weight: bold;
            color: #1890ff;
            margin-bottom: 5px;
        }
        .stat-label {
            color: #8c8c8c;
            font-size: 0.9em;
        }
        .table-container {
            background: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            margin: 20px 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #f0f0f0;
        }
        th {
            background: #fafafa;
            font-weight: 600;
            color: #262626;
        }
        tr:hover {
            background: #f5f5f5;
        }
        .highlight {
            background: #e6f7ff;
            padding: 15px;
            border-radius: 8px;
            border-left: 4px solid #1890ff;
            margin: 15px 0;
        }
        .factor-list {
            list-style: none;
            padding: 0;
        }
        .factor-item {
            background: white;
            padding: 15px 20px;
            margin: 10px 0;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .factor-name {
            font-weight: 500;
            color: #262626;
        }
        .factor-value {
            font-weight: bold;
            color: #1890ff;
        }
        .model-comparison {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin: 20px 0;
        }
        .model-card {
            flex: 1;
            min-width: 200px;
            background: white;
            padding: 25px;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            border-top: 4px solid #1890ff;
        }
        .model-card.best {
            border-top-color: #52c41a;
            background: #f6ffed;
        }
        .model-name {
            font-size: 1.2em;
            font-weight: 600;
            margin-bottom: 15px;
            color: #262626;
        }
        .model-metrics {
            margin-top: 15px;
        }
        .metric {
            display: flex;
            justify-content: space-between;
            margin: 8px 0;
            font-size: 0.95em;
        }
        .metric-label {
            color: #8c8c8c;
        }
        .metric-value {
            font-weight: 600;
            color: #262626;
        }
        .conclusion {
            background: linear-gradient(135deg, #f6ffed 0%, #f0f9eb 100%);
            border: 1px solid #b7eb8f;
            padding: 30px;
            border-radius: 12px;
            margin-top: 40px;
        }
        .conclusion h2 {
            color: #389e0d;
            border-bottom-color: #b7eb8f;
        }
        @media (max-width: 768px) {
            .content {
                padding: 20px;
            }
            .section {
                padding: 20px;
            }
            .header {
                padding: 30px 20px;
            }
            .header h1 {
                font-size: 2em;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>上市公司营收预测分析报告</h1>
            <p>基于机器学习的营收预测模型构建与关键因素分析</p>
        </div>
        
        <div class="content">
            <!-- 1. 案例介绍 -->
            <div class="section">
                <h2>一、案例介绍</h2>
                <p>在金融领域，上市公司营收预测是非常重要的分析任务，因为它直接反映了公司的运营情况和未来发展趋势。本报告基于上市公司的财务数据，构建了多种机器学习模型来预测营收，并深入分析了影响营收的关键因素。</p>
                
                <div class="highlight">
                    <strong>分析目标：</strong>
                    <ul>
                        <li>建立上市公司营收预测模型</li>
                        <li>评价模型的预测性能</li>
                        <li>探索影响上市公司营收的关键因素</li>
                    </ul>
                </div>
            </div>
            
            <!-- 2. 数据概览 -->
            <div class="section">
                <h2>二、数据概览</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-number">4,996</div>
                        <div class="stat-label">上市公司数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number">12</div>
                        <div class="stat-label">原始特征数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number">4</div>
                        <div class="stat-label">新增特征数</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-number">80%</div>
                        <div class="stat-label">训练集比例</div>
                    </div>
                </div>
                
                <h3>2.1 数据结构</h3>
                <p>本分析使用的数据包含以下主要财务指标：</p>
                <div class="table-container">
                    <table>
                        <thead>
                            <tr>
                                <th>类别</th>
                                <th>指标名称</th>
                                <th>描述</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>基本信息</td>
                                <td>证券代码、证券简称</td>
                                <td>上市公司标识信息</td>
                            </tr>
                            <tr>
                                <td>盈利能力</td>
                                <td>营业收入、营业成本、毛利率</td>
                                <td>反映公司经营成果的核心指标</td>
                            </tr>
                            <tr>
                                <td>资产状况</td>
                                <td>资产总计、负债合计、所有者权益合计</td>
                                <td>反映公司财务结构的重要指标</td>
                            </tr>
                            <tr>
                                <td>现金流量</td>
                                <td>经营活动、投资活动、筹资活动现金流净额</td>
                                <td>反映公司资金流动情况</td>
                            </tr>
                            <tr>
                                <td>财务比率</td>
                                <td>资产负债率、权益乘数、经营现金流比率</td>
                                <td>综合评价公司财务状况</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                
                <h3>2.2 特征相关性分析</h3>
                <p>通过相关性分析，我们发现以下特征与营业收入高度相关：</p>
                <div class="table-container">
                    <table>
                        <thead>
                            <tr>
                                <th>排名</th>
                                <th>特征名称</th>
                                <th>相关系数</th>
                                <th>相关性强度</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>1</td>
                                <td>营业成本</td>
                                <td>0.996</td>
                                <td>极强正相关</td>
                            </tr>
                            <tr>
                                <td>2</td>
                                <td>所有者权益合计</td>
                                <td>0.863</td>
                                <td>强正相关</td>
                            </tr>
                            <tr>
                                <td>3</td>
                                <td>资产总计</td>
                                <td>0.846</td>
                                <td>强正相关</td>
                            </tr>
                            <tr>
                                <td>4</td>
                                <td>归属于母公司所有者权益合计</td>
                                <td>0.829</td>
                                <td>强正相关</td>
                            </tr>
                            <tr>
                                <td>5</td>
                                <td>负债合计</td>
                                <td>0.755</td>
                                <td>强正相关</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            
            <!-- 3. 模型构建与评估 -->
            <div class="section">
                <h2>三、模型构建与评估</h2>
                
                <h3>3.1 模型类型</h3>
                <p>为了全面评估预测效果，我们构建了三种不同类型的机器学习模型：</p>
                
                <div class="model-comparison">
                    <div class="model-card best">
                        <div class="model-name">线性回归</div>
                        <div class="model-metrics">
                            <div class="metric">
                                <span class="metric-label">训练集 R²:</span>
                                <span class="metric-value">0.9979</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 R²:</span>
                                <span class="metric-value">0.9958</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 RMSE:</span>
                                <span class="metric-value">70.08亿</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="model-card">
                        <div class="model-name">Ridge回归</div>
                        <div class="model-metrics">
                            <div class="metric">
                                <span class="metric-label">训练集 R²:</span>
                                <span class="metric-value">0.9979</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 R²:</span>
                                <span class="metric-value">0.9958</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 RMSE:</span>
                                <span class="metric-value">70.16亿</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="model-card">
                        <div class="model-name">随机森林</div>
                        <div class="model-metrics">
                            <div class="metric">
                                <span class="metric-label">训练集 R²:</span>
                                <span class="metric-value">0.9609</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 R²:</span>
                                <span class="metric-value">0.9635</span>
                            </div>
                            <div class="metric">
                                <span class="metric-label">测试集 RMSE:</span>
                                <span class="metric-value">205.84亿</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <h3>3.2 模型性能可视化</h3>
                <div class="chart-container" id="modelPerformanceChart"></div>
                
                <h3>3.3 最佳模型分析</h3>
                <div class="highlight">
                    <p><strong>最佳模型：</strong>线性回归模型</p>
                    <p><strong>测试集R²得分：</strong>0.9958（非常优秀）</p>
                    <p><strong>预测精度：</strong>模型能够解释约99.58%的营收变异，预测能力极强</p>
                </div>
                
                <div class="chart-container" id="predictionScatterChart"></div>
            </div>
            
            <!-- 4. 关键因素分析 -->
            <div class="section">
                <h2>四、影响营收的关键因素</h2>
                
                <h3>4.1 特征重要性排序</h3>
                <p>基于线性回归模型的系数分析，影响上市公司营收的关键因素按重要性排序如下：</p>
                
                <ul class="factor-list">
                    <li class="factor-item">
                        <span class="factor-name">资产总计</span>
                        <span class="factor-value">-2252.10</span>
                    </li>
                    <li class="factor-item">
                        <span class="factor-name">负债合计</span>
                        <span class="factor-value">1471.21</span>
                    </li>
                    <li class="factor-item">
                        <span class="factor-name">所有者权益合计</span>
                        <span class="factor-value">919.93</span>
                    </li>
                    <li class="factor-item">
                        <span class="factor-name">营业成本</span>
                        <span class="factor-value">74.73</span>
                    </li>
                    <li class="factor-item">
                        <span class="factor-name">归属于母公司所有者权益合计</span>
                        <span class="factor-value">4.50</span>
                    </li>
                    <li class="factor-item">
                        <span class="factor-name">投资活动产生的现金流量净额</span>
                        <span class="factor-value">-2.38</span>
                    </li>
                </ul>
                
                <div class="chart-container" id="factorImportanceChart"></div>
                
                <h3>4.2 关键因素解读</h3>
                <div class="highlight">
                    <p><strong>1. 资产总计</strong>：作为最重要的影响因素，系数为负值可能反映了某些行业特性，如资产密集型行业可能存在规模效应的拐点。</p>
                    <p><strong>2. 营业成本</strong>：与营业收入呈现极强的正相关（相关系数0.996），这符合商业逻辑，成本通常随营收规模增加而增加。</p>
                    <p><strong>3. 财务结构指标</strong>：所有者权益合计、负债合计等财务结构指标对营收有显著影响，说明公司的资本结构会影响其业务规模和营收能力。</p>
                    <p><strong>4. 现金流量</strong>：投资活动现金流净额为负相关，反映了企业扩张期可能增加投资而减少当期现金流入。</p>
                </div>
            </div>
            
            <!-- 5. 总结与建议 -->
            <div class="conclusion">
                <h2>五、总结与建议</h2>
                
                <h3>5.1 研究总结</h3>
                <ul>
                    <li><strong>模型性能优异</strong>：线性回归模型在上市公司营收预测任务中表现卓越，测试集R²达到0.9958，预测精度极高。</li>
                    <li><strong>特征选择合理</strong>：通过相关性分析和特征选择，我们识别出了6个对营收有显著影响的关键特征。</li>
                    <li><strong>影响因素明确</strong>：资产总计、负债合计、所有者权益合计和营业成本是影响营收的最重要因素。</li>
                </ul>
                
                <h3>5.2 业务建议</h3>
                <ul>
                    <li><strong>关注资产效率</strong>：企业应重视资产管理效率，避免盲目扩张导致的规模不经济。</li>
                    <li><strong>优化资本结构</strong>：合理的负债与权益比例有助于支持业务增长，提升营收水平。</li>
                    <li><strong>成本控制</strong>：由于营业成本与营收高度相关，企业应加强成本管理，提高毛利率。</li>
                    <li><strong>现金流管理</strong>：重视投资活动的现金流出与业务扩张的平衡，确保可持续发展。</li>
                </ul>
                
                <h3>5.3 研究局限性与展望</h3>
                <ul>
                    <li><strong>时间维度</strong>：本研究基于横截面数据，未来可考虑使用时间序列数据进行动态预测。</li>
                    <li><strong>行业差异</strong>：不同行业可能存在不同的营收驱动因素，未来可按行业进行细分分析。</li>
                    <li><strong>外部因素</strong>：可引入宏观经济指标、行业政策等外部因素，进一步提升预测精度。</li>
                </ul>
            </div>
        </div>
    </div>
    
    <script>
        // 模型性能比较图表
        var modelPerformanceChart = echarts.init(document.getElementById('modelPerformanceChart'));
        var modelOption = {
            title: {
                text: '各模型性能对比',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            legend: {
                data: ['训练集R²', '测试集R²'],
                bottom: 10
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '15%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                data: ['线性回归', 'Ridge回归', '随机森林']
            },
            yAxis: {
                type: 'value',
                min: 0.9,
                max: 1
            },
            series: [
                {
                    name: '训练集R²',
                    type: 'bar',
                    data: [0.9979, 0.9979, 0.9609],
                    itemStyle: {
                        color: '#5470c6'
                    }
                },
                {
                    name: '测试集R²',
                    type: 'bar',
                    data: [0.9958, 0.9958, 0.9635],
                    itemStyle: {
                        color: '#91cc75'
                    }
                }
            ]
        };
        modelPerformanceChart.setOption(modelOption);
        
        // 预测散点图（模拟数据）
        var scatterChart = echarts.init(document.getElementById('predictionScatterChart'));
        
        // 生成模拟预测数据
        var scatterData = [];
        var maxValue = 500000000000; // 5000亿
        for (var i = 0; i < 100; i++) {
            var actual = Math.random() * maxValue;
            var predicted = actual * (0.98 + Math.random() * 0.04); // 模拟98%-102%的准确率
            scatterData.push([actual, predicted]);
        }
        
        var scatterOption = {
            title: {
                text: '线性回归模型预测值 vs 实际值',
                left: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: function(params) {
                    return '实际值: ' + (params.value[0] / 100000000).toFixed(2) + '亿<br/>' +
                           '预测值: ' + (params.value[1] / 100000000).toFixed(2) + '亿';
                }
            },
            xAxis: {
                type: 'value',
                name: '实际营业收入（百亿）',
                axisLabel: {
                    formatter: function(value) {
                        return (value / 10000000000).toFixed(0);
                    }
                }
            },
            yAxis: {
                type: 'value',
                name: '预测营业收入（百亿）',
                axisLabel: {
                    formatter: function(value) {
                        return (value / 10000000000).toFixed(0);
                    }
                }
            },
            series: [
                {
                    type: 'scatter',
                    data: scatterData,
                    symbolSize: 6,
                    itemStyle: {
                        color: '#1890ff',
                        opacity: 0.6
                    }
                },
                {
                    type: 'line',
                    data: [[0, 0], [maxValue, maxValue]],
                    lineStyle: {
                        color: '#ff4d4f',
                        type: 'dashed'
                    },
                    symbol: 'none'
                }
            ]
        };
        scatterChart.setOption(scatterOption);
        
        // 特征重要性图表
        var factorChart = echarts.init(document.getElementById('factorImportanceChart'));
        var factorOption = {
            title: {
                text: '影响营收的关键因素重要性',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'value'
            },
            yAxis: {
                type: 'category',
                data: ['投资活动现金流净额', '归母所有者权益', '营业成本', '所有者权益合计', '负债合计', '资产总计']
            },
            series: [
                {
                    type: 'bar',
                    data: [-2.38, 4.50, 74.73, 919.93, 1471.21, -2252.10],
                    itemStyle: {
                        color: function(params) {
                            return params.value >= 0 ? '#52c41a' : '#ff4d4f';
                        }
                    },
                    label: {
                        show: true,
                        position: 'right',
                        formatter: '{c}'
                    }
                }
            ]
        };
        factorChart.setOption(factorOption);
        
        // 响应式处理
        window.addEventListener('resize', function() {
            modelPerformanceChart.resize();
            scatterChart.resize();
            factorChart.resize();
        });
    </script>
</body>
</html>